﻿<Window x:Class="cmdr.Editor.Views.AppSettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:cmdr.Editor.Converters"
        Title="{Binding Title, Mode=OneWay}" Height="300" MinHeight="300" Width="600" MinWidth="600"
        WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <converters:InverseBooleanConverter x:Key="invBoolConverter"/>
        <BooleanToVisibilityConverter x:Key="boolToVisConverter"/>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="Escape" Command="{Binding CloseCommand, Mode=OneTime}"/>
    </Window.InputBindings>
    <DockPanel LastChildFill="True" Margin="10">

        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Height="25" HorizontalAlignment="Right">
            <Button Content="Save" Margin="0,0,10,0" Command="{Binding SaveCommand, Mode=OneTime}"/>
            <Button Content="Cancel" Command="{Binding CloseCommand, Mode=OneTime}"/>
        </StackPanel>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="50"/>
                <RowDefinition Height="50"/>
                <RowDefinition Height="50"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center">
                <Label Padding="5,0">Default workspace:</Label>
                <Label Padding="5,0" FontSize="10">This is where your mappings are</Label>
            </StackPanel>
            <Grid Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Border BorderThickness="1,1,0,1" BorderBrush="LightGray" Height="20">
                    <TextBlock x:Name="tbDefaultWorkspace" Text="{Binding DefaultWorkspace, Mode=TwoWay}" 
                                   VerticalAlignment="Center" />
                </Border>
                <Button Grid.Column="1" Width="20" Height="20" Content="..." Command="{Binding BrowseFolderCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=tbDefaultWorkspace}"/>
            </Grid>

            <StackPanel Grid.Row="1" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center">
                <Label Padding="5,0">Path to controller default mappings:</Label>
                <Label Padding="5,0" FontSize="10">Usually: /Traktor {Version}/Settings/Default Settings/Controller</Label>
            </StackPanel>
            <Grid Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Border BorderThickness="1,1,0,1" BorderBrush="LightGray" Height="20">
                    <TextBlock x:Name="tbPathToControllerDefaultMappings" Text="{Binding PathToControllerDefaultMappings, Mode=TwoWay}" 
                               VerticalAlignment="Center" />
                </Border>
                <Button Grid.Column="1" Width="20" Height="20" Content="..." Command="{Binding BrowseFolderCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=tbPathToControllerDefaultMappings}"/>
            </Grid>

            <StackPanel Grid.Row="2" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center">
                <Label Padding="5,0">Path to "Traktor Settings.tsi":</Label>
                <Label Padding="5,0" FontSize="10">Usually: /Traktor {Version}/Traktor Settings.tsi</Label>
            </StackPanel>
            <Grid Grid.Row="2" Grid.Column="1" VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Border BorderThickness="1,1,0,1" BorderBrush="LightGray" Height="20">
                    <TextBlock x:Name="tbTraktorSettings" Text="{Binding PathToTraktorSettings, Mode=TwoWay}" 
                               VerticalAlignment="Center" />
                </Border>
                <Button Grid.Column="1" Width="20" Height="20" Content="..." Command="{Binding BrowseFileCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=tbTraktorSettings}"/>
            </Grid>

            <StackPanel Grid.Row="3" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center">
                <Label Padding="5,0">Traktor version:</Label>
                <Label Padding="5,0" FontSize="10">This is what is written into TSI files, so Traktor can check compatibility</Label>
            </StackPanel>
            <Grid Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" IsEnabled="{Binding IsInitializingTraktorSettings, Converter={StaticResource invBoolConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBox IsReadOnly="{Binding OverrideTraktorVersion, Converter={StaticResource invBoolConverter}}"
                         BorderBrush="LightGray"
                         Text="{Binding TraktorVersion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         Height="20" HorizontalAlignment="Stretch">
                    <TextBox.Style>
                        <Style TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding OverrideTraktorVersion}" Value="False">
                                    <Setter Property="FontStyle" Value="Italic"/>
                                    <Setter Property="Foreground" Value="#888"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding OverrideTraktorVersion}" Value="True">
                                    <Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}"/>
                                </DataTrigger>

                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>
                <CheckBox Grid.Column="1" Margin="10,0" Width="Auto" Height="20" VerticalContentAlignment="Center" Content="Override" IsChecked="{Binding OverrideTraktorVersion, Mode=TwoWay}" IsEnabled="{Binding MustOverrideTraktorVersion, Converter={StaticResource invBoolConverter}}"/>
            </Grid>

        </Grid>

    </DockPanel>
</Window>
